package com.vcms.cms.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 * UserGroup entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "user_group", catalog = "vcms_0.1")
public class UserGroup implements java.io.Serializable {

	// Fields

	private Integer userGroupId;
	private String userGroupName;
	private Integer priority;
	private Boolean needCaptcha;
	private Boolean needCheck;
	private Integer allowPerDay;
	private Integer allowMaxFile;
	private String allowSuffix;
	private Boolean isRegDef;
	private Set<Channel> viewChannels = new HashSet<Channel>(0);
	private Set<Channel> contributeChannels = new HashSet<Channel>(0);
	private Set<Content> contents = new HashSet<Content>(0);

	// Constructors

	/** default constructor */
	public UserGroup() {
	}

	/** full constructor */
	public UserGroup(String userGroupName, Integer priority,
			Boolean needCaptcha, Boolean needCheck, Integer allowPerDay,
			Integer allowMaxFile, String allowSuffix, Boolean isRegDef,
			Set<Channel> viewChannels, Set<Channel> contributeChannels,
			Set<Content> contents) {
		this.userGroupName = userGroupName;
		this.priority = priority;
		this.needCaptcha = needCaptcha;
		this.needCheck = needCheck;
		this.allowPerDay = allowPerDay;
		this.allowMaxFile = allowMaxFile;
		this.allowSuffix = allowSuffix;
		this.isRegDef = isRegDef;
		this.viewChannels = viewChannels;
		this.contributeChannels = contributeChannels;
		this.contents = contents;
	}

	// Property accessors
	@Id
	@GeneratedValue
	@Column(name = "userGroupId", unique = true, nullable = false)
	public Integer getUserGroupId() {
		return this.userGroupId;
	}

	public void setUserGroupId(Integer userGroupId) {
		this.userGroupId = userGroupId;
	}

	@Column(name = "userGroupName", length = 200)
	public String getUserGroupName() {
		return this.userGroupName;
	}

	public void setUserGroupName(String userGroupName) {
		this.userGroupName = userGroupName;
	}

	@Column(name = "priority")
	public Integer getPriority() {
		return this.priority;
	}

	public void setPriority(Integer priority) {
		this.priority = priority;
	}

	@Column(name = "needCaptcha")
	public Boolean getNeedCaptcha() {
		return this.needCaptcha;
	}

	public void setNeedCaptcha(Boolean needCaptcha) {
		this.needCaptcha = needCaptcha;
	}

	@Column(name = "needCheck")
	public Boolean getNeedCheck() {
		return this.needCheck;
	}

	public void setNeedCheck(Boolean needCheck) {
		this.needCheck = needCheck;
	}

	@Column(name = "allowPerDay")
	public Integer getAllowPerDay() {
		return this.allowPerDay;
	}

	public void setAllowPerDay(Integer allowPerDay) {
		this.allowPerDay = allowPerDay;
	}

	@Column(name = "allowMaxFile")
	public Integer getAllowMaxFile() {
		return this.allowMaxFile;
	}

	public void setAllowMaxFile(Integer allowMaxFile) {
		this.allowMaxFile = allowMaxFile;
	}

	@Column(name = "allowSuffix", length = 300)
	public String getAllowSuffix() {
		return this.allowSuffix;
	}

	public void setAllowSuffix(String allowSuffix) {
		this.allowSuffix = allowSuffix;
	}

	@Column(name = "isRegDef")
	public Boolean getIsRegDef() {
		return this.isRegDef;
	}

	public void setIsRegDef(Boolean isRegDef) {
		this.isRegDef = isRegDef;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "channel_view_user", catalog = "vcms_0.1", joinColumns = { @JoinColumn(name = "userGroupId", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "channelId", nullable = false, updatable = false) })
	public Set<Channel> getViewChannels() {
		return viewChannels;
	}

	public void setViewChannels(Set<Channel> viewChannels) {
		this.viewChannels = viewChannels;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "channel_contribute_user", catalog = "vcms_0.1", joinColumns = { @JoinColumn(name = "userGroupId", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "channelId", nullable = false, updatable = false) })
	public Set<Channel> getContributeChannels() {
		return contributeChannels;
	}

	public void setContributeChannels(Set<Channel> contributeChannels) {
		this.contributeChannels = contributeChannels;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "content_view_user", catalog = "vcms_0.1", joinColumns = { @JoinColumn(name = "userGroupId", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "contentId", nullable = false, updatable = false) })
	public Set<Content> getContents() {
		return this.contents;
	}

	public void setContents(Set<Content> contents) {
		this.contents = contents;
	}

}